<?php

namespace app\model;

use think\Model;
use think\model\relation\HasOne;

class StationChange extends Model
{
    public function station(): HasOne
    {
        return $this->hasOne(StationBasic::class, "id", "station_id");
    }

    public function lst(): array
    {
        $param = request()->param();
        $station = request()->station ?? [];
        $data = $this->with(["station"])->when(!empty($station), function ($query) use ($station) {
            $query->where("station_id", $station['id']);
        })->order("create_time", "desc")->paginate([
            "list_rows" => $param["size"] ?? 30,
            "page" => $param['page'] ?? 1
        ])->toArray();
        return pageData($data);
    }
}
